// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import VueRouter from 'vue-router';
import VueResource from 'vue-resource';
import App from './App';
import goods from 'components/goods/goods';
import ratings from 'components/ratings/ratings';
import seller from 'components/seller/seller';

import 'commen/stylus/index.styl';

Vue.use(VueRouter);
Vue.use(VueResource);
Vue.config.productionTip = false;
console.log(typeof App);
let App1 = Vue.extend(App);// 创建组件构造器
console.log(typeof App1);
// 定义路由,每个路由都应该映射一个组件,其中component可以使通过vue.extend()创建的组件构造器;也可以是一个组件配置对象
const routes = [
  {path: '/goods', component: goods},
  {path: '/ratings', component: ratings},
  {path: '/seller', component: seller}
  // {path: '/', component: goods}
  // {path: '/', redirect: '/goods'}
  // {path: '/seller', redirect: {name: 'goods'}}
];

// 3.创建router实例,然后传routes配置,还可以传其他配置参数。。。比如linkActiveClass全局配置<router-link>的激活class类名
const router = new VueRouter({
  routes, // （缩写）相当于 routes: routes
  linkActiveClass: 'active'
});

// 创建和挂载根实例,记得要通过router配置参数注入路由，从而让整个应用都拥有路由功能.
let app = new App1({
  router
});
app.$mount('#app');

router.push('/goods');
